import Vue from 'vue'
import Vuex from 'vuex'
import createLogger from 'vuex/dist/logger'

import status from './modules/status'
import totals from './modules/totals'
import riskList from './modules/riskList'
import warnDetail from './modules/warnDetail'

// const path = require('path')
// const fs = require('fs')

Vue.use(Vuex);

const debug = process.env.NODE_ENV !== 'production';

// const dirPath = path.resolve(__dirname, '../modules');
// let files = fs.readFileSync(dirPath);
// let modules = {};
// files.forEach((val, index) => {
//     let pathName = val.replace(/\.js$/, '');
//     let temp = require('./modules/' + pathName);
//     modules[pathName] = temp;
// });

export default new Vuex.Store({
    modules: {
        status,
        totals,
        riskList,
        warnDetail
    },
    strict: debug,
    plugins: debug ? [createLogger()] : []
});
